<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Edit Info</title>

<link href="../jQueryAssets/jquery.ui.core.min.css" rel="stylesheet" type="text/css">
<link href="../jQueryAssets/jquery.ui.theme.min.css" rel="stylesheet" type="text/css">
<link href="../jQueryAssets/jquery.ui.tabs.min.css" rel="stylesheet" type="text/css">
<script src="../jQueryAssets/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="../jQueryAssets/jquery-ui-1.9.2.tabs.custom.min.js" type="text/javascript"></script>
<script type="text/javascript" src="../tinymce/js/tinymce/tinymce.min.js"></script>
<link href="../css/einfo-style.css" rel='stylesheet' type='text/css'>

<script type="text/javascript">
tinymce.init({
 selector: "textarea",
plugins: [
            "advlist autolink autosave link image lists charmap print preview hr anchor pagebreak spellchecker",
            "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
            "table contextmenu directionality emoticons template textcolor paste fullpage textcolor"
    ],
 toolbar: "insertfile undo redo | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent",
  menubar: false,
    toolbar_items_size: 'small',
	
    height: "100",
    width:700,
 });
</script>


<?php

include('../php/db.php');

if ($_SESSION['login'] == NULL)
{
 header("Location: ../index.php");	
}
else
{
$login = $_SESSION['login'];

$userid = mysql_query("SELECT `account_id` FROM `flss`.`accounts` WHERE `user` = '$login'");
while($rowshow = mysql_fetch_array($userid))
{
	$getrow = $rowshow['account_id'];
}
$getrowname = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getrow' ") or die(mysql_error);
$getrowdesc = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getrow' ") or die(mysql_error);
$getrowwju = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getrow' ") or die(mysql_error);
$getrowregno = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getrow' ") or die(mysql_error);
$getrowindust = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getrow' ") or die(mysql_error);
$getrowcompsize = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getrow' ") or die(mysql_error);
$getrowworkhrs = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getrow' ") or die(mysql_error);
$getrowdresscode = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getrow' ") or die(mysql_error);
$getrowbenefits = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getrow' ") or die(mysql_error);
$getrowspokenlanguage = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getrow' ") or die(mysql_error);



while($row = mysql_fetch_array($getrowname))
{
  $clogo = $row['logo'];
  $ccover = $row['cover'];
}


$logo = empty($clogo) ? DEFAULT_LOGO : IMAGE_URL_SMALL.$clogo; 
$cover = empty($ccover) ? DEFAULT_COVER : IMAGE_URL_SMALL.$ccover;
$employer_id = $getrow;


}


?>


<?php
if(isset($_POST['btnSubmitCname']))
{
	$updatecname = $_POST['companyname'];
	mysql_query("UPDATE `employer` SET `ename`= '$updatecname' WHERE `employer_id` = '$getrow'") or die(mysql_error());
	header("Refresh:0");
	}
if(isset($_POST['btnSubmitOverview']))
{
	$updateoverview = addslashes($_POST['companyoverview']);
	mysql_query("UPDATE `employer` SET `description`= '$updateoverview' WHERE `employer_id` = '$getrow'") or die(mysql_error());
	header("Refresh:0");
	}
if(isset($_POST['btnSubmitWju']))
{
	$updatewju = addslashes($_POST['whyjoinus']);
	mysql_query("UPDATE `employer` SET `whyjoinus`= '$updatewju' WHERE `employer_id` = '$getrow'") or die(mysql_error());
	header("Refresh:0");
	}
if(isset($_POST['btnSubmitComSnap']))
{
	$updatereg = $_POST['regno'];
	$updateind = $_POST['industype'];
	$updatesize = $_POST['comsize'];
	$updatewh = $_POST['workhrs'];
	$updatedc = $_POST['dcode'];
	$updateben = $_POST['content_benefits'];
	$updatesl = $_POST['spokenlang'];
	mysql_query("UPDATE `e_snap` SET `Registration_No`='$updatereg',`Industry`='$updateind',`Company_size`='$updatesize',`Working_hours`='$updatewh',`Dresscode`='$updatedc',`Benefits`='$updateben',`Spoken_language`='$updatesl' WHERE `e_id` = '$getrow'") or die(mysql_error());
	header("Refresh:0");
	}
if(isset($_POST['btnSubmitComloc']))
{
	$loc = addslashes($_POST['comloc']);
	mysql_query("UPDATE `e_map` SET `e_address`='$loc' WHERE employer_id = '$getrow'");
	}

?>

</head>
<body>

<div class="h-top">
<div class="h-top-logo">

<a href="#"> <img src="../images/handlogo.png" height="50"> </a>
 
</div>
<div id="nav">
    <div id="nav_wrapper">
        <ul>
            <li><a href="employer.php">Home</a>
            </li>
            <li> <a href="postjob.php">Post Job</a>
            </li>
               <li> <a href="candidates.php">Candidates</a>
            </li>
            <li> <a href="#">Account <img src="../images/dropdownicon.png" style="position:relative; width:15px; height:15px; top:5px;"></a>

                <ul>
                    <li> <a href="../php/logout.php" name="logout">Logout</a>
                    	
                    </li>
                    <li><a href="#">Help</a>
                    </li>
                    <li><a href="#">My Account </a>
                    </li>
                </ul>
            </li>
            
            
        </ul>
    </div>
    <!-- Nav wrapper end -->
</div>
<!-- Nav end -->
</div>

<div class="b-sub-container">
	<div class="b-content">
		<div class="b-image-upload">
    	<img id="companyCover" width = "960" height = "250" src="<?=$cover?>"/> 
    				<div class="coverbutton">
					<a id="uploadCover">
                   <label for="FileInputCover">
                        <img src="../images/camerapic.png" Style="height:20px; cursor:pointer;  margin-top:20px; margin-left:20px;" >
                    </label>
                     <input id="InputCover" type="file"  style="display: none"/>
                   <span class="text-content"><span>&nbsp;&nbsp;Update Cover</span> </span>  </a>
                   </div>

     	</div>
     </div>
        <div class="b-sub-content">
            <div class="b-company-logo">
              <img id="companyLogo" width = "150" height = "150" src="<?=$logo?>"/>
             		<div class="b-image-button">	
                    <a id="uploadLogo">
                    <label for="FileInputlogo">
                    	<img src="../images/camerapic.png" Style="height:20px; cursor:pointer;">
                    </label>

                  
                    <span class="text-content"><span>&nbsp;&nbsp;Update logo</span> </span>  </a>

       		       </div>
            </div>

       </div>
        <div class="b-info-header">
     		<div class="header-about-content">
        		<div class="header-text">
                	<p> About </p>
                </div>    
            </div>
        </div>


    <div id="Tabs1">
        <ul>
          <li ><a href="#tabs-1">Company</a></li>
          <li><a href="#tabs-2">Overview</a></li>
          <li><a href="#tabs-3">Why Join Us?</a></li>
          <li><a href="#tabs-4">Snapshot</a></li>
          <li><a href="#tabs-5">Location</a></li>
        </ul>
       
        <div id="tabs-1" >
        <form method="post">
          <table>
          <tr>
          <td><label for="companyname"> Company Name </label></td>
          </tr>
          <tr>
          <td><input type="text" name="companyname" value='<?php  while ($rowname = mysql_fetch_array($getrowname)) {
			 						$nameko = $rowname['ename'];
									
    						} ?>'> <?=$nameko?></td>
           
           </tr>
           <tr>
        	<td>
        	  <input type="submit" name="btnSubmitCname"  value="UPDATE">
        	</td>
            </tr>
            </table>
        </form>
        </div>
        <div id="tabs-2" >
           <form method="post">
          <table>
            <tr>
              <td><label for="companyoverview"> Company Overview </label></td>
            </tr>
            <tr>
              <td><textarea name="companyoverview" > <?php  while ($row2 = mysql_fetch_array($getrowdesc)) {
			 						echo $row2['description'];
    						} ?> 
      				</textarea></td>
            </tr>
            <tr>
              <td><input type="submit" value="UPDATE" name="btnSubmitOverview"></td>
            </tr>
          </table>
          </form>
        </div>
        <div id="tabs-3" >
           <form method="post">
          <table>
     		 <tr>
               <td><label for="companywhyjoinus"> Why Join Us </label></td>
                    </tr>
                    <tr> 
                    <td><textarea name="whyjoinus" ><?php  while ($row3 = mysql_fetch_array($getrowwju)) {
			 						echo $row3['whyjoinus'];
    						} ?> </textarea></td>
                     </tr>
                     <tr>
                     <td><input type="submit" value="UPDATE" name="btnSubmitWju"> </td>
                     </tr>
                     </table>
                    </form>
        </div>
        <div id="tabs-4" >
         <form method="post">
				<table>
                    <tr>
                    <td><label for="companysnapshot"> Company Snapshot </label> </td>
                    </tr>
                    <tr>
                    <td>Registration NO: </td>
                    <td><input type="text" name="regno" value='<?php  while ($row4 = mysql_fetch_array($getrowregno)) {
			 						echo $row4['Registration_No'];
    						} ?>'> 
                     </td>
                    </tr>
                    <tr>
                    <td>Industry Type: </td>
                    <td><input type="text" name="industype" value='<?php  while ($row5 = mysql_fetch_array($getrowindust)) {
			 						echo $row5['Industry'];
    						} ?>'> </td>
                    </tr>
                    <tr>
                    <td>Company Size: </td>
                    <td><input type="text" name="comsize" value='<?php  while ($row6 = mysql_fetch_array($getrowcompsize)) {
			 						echo $row6['Company_size'];
    						} ?>'> </td>
                    </tr>
                    <tr>
                    <td>Working Hours: </td> 
                    <td><input type="text" name="workhrs" value='<?php  while ($row7 = mysql_fetch_array($getrowworkhrs)) {
			 						echo $row7['Working_hours'];
    						} ?>'> </td>
                    </tr>
                    <tr>
                    <td>Dresscode: </td>
                    <td> <input type="text" name="dcode" value="<?php  while ($row8 = mysql_fetch_array($getrowdresscode)) {
			 						echo $row8['Dresscode'];
    						} ?>"> </td>
                    </tr>
                    <tr>
                    <td>Benefits: </td>
                    <td><textarea name="content_benefits"><?php  while ($row9 = mysql_fetch_array($getrowbenefits)) {
			 						echo $row9['Benefits'];
    						} ?> </textarea> </td>
                    </tr>
                    <tr>
                    <td>Spoken Language: </td>
                    <td><input type="text" name="spokenlang" value='<?php  while ($row10 = mysql_fetch_array($getrowspokenlanguage)) {
			 						echo $row10['Spoken_language'];
    						} ?>'> </td>
                    </tr>
                    <tr>
                    <td><input type="submit" name="btnSubmitComSnap" value="UPDATE"> </td>
                    </tr>
                    </table>
                    </form>
                            </div>
        <div id="tabs-5">
         <form method="post">
          <label for="companyloc" > Company Location </label> 
          <table>
          <tr>
          <td>
          Please click the link below and generate a map
          </td>
          </tr>
          <tr>
          <tr>
          <td>
          Set Height: 250 and Width: 269
          </td>
          </tr>
          <td>
          <a href="http://www.map-embed.com/" style="color:#F001FF;" target="new"> Click Me </a>
          </td>
          </tr>
          <tr>
         <td> <input type="text" name="comloc"> </td>
		</tr>
        <tr>
        <td> <input type="submit" name="btnSubmitComloc" value="UPDATE"> </td>
        </tr>
        </table>
      </form>
    
        </div>
    </div>
     <input type="file" id="logoFile" style="display:none"/>
<script type="text/javascript">
     $(function() {
        $( "#Tabs1" ).tabs(); 
     
        function uploadPhoto(employer_id,type,from)
        { 
           var params = {};
           params.employer_id = employer_id;
           params.type = type;
           params.from = from;
           return $.ajax({
              url: '../api/upload.php',
              data: params,
              type: 'post',
              dataType : 'json'
           });

        }

        function readURL(input,type)
        {
            if (input.files && input.files[0]) {
                var reader = new FileReader();
                reader.onload = function (e) {
                    path = e.target.result;

                    uploadPhoto("<?=$employer_id?>",type,path).done(function(result){
                      if(result.status == "true")
                      {
                          if(type == "logo")
                          {

                            $('#companyLogo').attr('src',path); 
                          }
                          else
                          {
                            $('#companyCover').attr('src',path);
                          }   
                      }
                      else
                      {
                         alert('There is a problem uploading your photo please try again later');
                      }
                    });
                    
                    
                }
                reader.readAsDataURL(input.files[0]);
            }
        }

        var type = "";

        $('#uploadCover').click(function(){
            $('#logoFile').click();
            type = "cover";
            return false;
        });


        $('#uploadLogo').click(function(){
            $("#InputCover").click();
            type = "logo";
            return false;
        });

        $('#InputCover').change(function(){
            readURL(this,type);
        });

         $('#logoFile').change(function(){
            readURL(this,type);
        });
       


       });
	  
</script>
			


</div> 
<div class="footer">
        	
            <div style="margin-top:20px; float:left; width:100%;">
            <center>
            
            <p>Copyright @ Famous Labor Supply Service Alright Reserve 2015</p>
            </center>
            </div>
        </div>   			


</body>
</html>
